package com.gome.han.cloud.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import com.gome.han.springcloud.api.bean.User;

/**
* @author hanpeng
* @version 创建时间：2020年8月8日 下午1:09:37
* @ClassName 类名称
* @Description 类描述
*/
@RestController
public class UserController {
	@Autowired
	private RestTemplate restTemplate;
	//private  static final String REST_URL_PREFIX="http://localhost:8081/";
	private  static final String REST_URL_PREFIX="http://SPRING-CLOUD-PROVIDER1/";
	@RequestMapping("/consumer/get/{age}")
	public User getUser(@PathVariable(name="age") Integer age) {
		User user = restTemplate.getForObject(REST_URL_PREFIX+"getUser/"+age,  User.class);
		return user;
	}
	

}
